<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
<script type="text/javascript">
jQuery(document).ready(
  function(){
    jQuery("#adminForm").validate({
      rules:  {
        video: "required",
        video_type: "required",
        video_id: {
          required: true,
          digits: true
        },
      }
    });
  }
);
</script>
  <fieldset class="adminform">
    <legend>Details</legend>
      <? 
        $id        = 0;
        $video          = null;
        $description    = null;
        $video_id    = null;
        $video_type     = null;
        $video_embed    = null;
        $published    = true;
        
        if(isset($this->video)){
          $id        = $this->video->id;
          $description    = $this->video->description;
          $video          = $this->video->video;
          $video_embed    = $this->video->video_embed;
          $video_id    = $this->video->video_id;
          $video_type     = $this->video->video_type;
          $published    = $this->video->published;  
        }
        
      ?>
      <table class="admintable">
        <tr>
          <td></td>
          <td>
            <? if($video_embed){ ?>
            <div id="watch-player" class="flash-player">
              <iframe class="youtube-player" type="text/html" width="640" height="385" src="<?= $video_embed ?>" frameborder="0">
              </iframe>
            </div>
            <? } ?>
          </td>
        </tr>
        <tr>
          <td class="key">Url</td>
          <td>
            <textarea id="video" name="video" rows="2" cols="40" ><?= $video ?></textarea>
          </td>
        </tr>
        <tr>
          <td class="key">Description</td>
          <td>
            <textarea id="description" name="description" rows="4" cols="40" ><?= $description ?></textarea>
          </td>
        </tr>
        <tr>
                    <td class="key">Type</td>
          <td>
            <select id="video_type" name="video_type" onchange="ajx_request('<?= JRequest::getVar('c', 'video') ?>', 'get_type_instances',  'type='+this.value, 'type_instance_container')">
              <option value="">NONE</option>
              <? foreach($this->video_types as $type){ 
                $selected = '';
                if($type == $video_type)
                  $selected = 'selected'
              ?>
                
                <option value="<?= $type ?>" <?= $selected ?>><?= $type ?></option>
              <? } ?>
            </select>
          </td>
        </tr>
        <tr>
                    <td class="key">Type Instance</td>
          <td>
            <div id="type_instance_container">
              <select id='video_id' name='video_id'>
                <? if(isset($this->video_type_instances)){ 
                    foreach($this->video_type_instances as $k => $text){ 
                      $selected = '';
                      if($k == $video_id)
                        $selected = 'selected'
                    ?>
                      <option value="<?= $k ?>" <?= $selected ?>><?= $text ?></option>    
                <?     }  
                   } ?>
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <td class="key">Published</td>
          <td>
            <?= JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $published); ?>
          </td>
        </tr>
             </table>
       </fieldset>
       <input type="hidden" name="option" value="<?= JRequest::getVar( 'option' );?>"/>
     <input type="hidden" name="c" value="<?= JRequest::getVar('c', 'season'); ?>" />
       <input type="hidden" name="id" value="<?= $id; ?>"/>
     <input type="hidden" name="task" value=""/>
</form>